// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   OptConfirmScrPanel.java

package com.boci.clientapp.trading;

import com.boci.clientapp.main.ClientAppLoader;
import com.boci.clientapp.trading.action.OptConfirmAction;
import com.boci.clientapp.trading.vo.SendHKOptionVO;
import com.boci.clientapp.trading.vo.SendUSOptionVO;
import com.boci.common.constant.ClientAppConst;
import com.boci.common.ui.AbstractPanel;
import com.boci.common.util.*;
import com.boci.common.vo.ResponseVO;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Locale;
import javax.swing.*;

public class OptConfirmScrPanel extends AbstractPanel
{

    public OptConfirmScrPanel(Locale pLocale, String pModuleName, String pScreenName)
    {
        super(pLocale, pModuleName, pScreenName);
        msgConf = ClientAppLoader.getMessagesConfigurator();
        intHIndex = 10;
        intVIndex = 2;
        initGUI(pLocale);
        setText(pLocale);
    }

    private void setFont(Locale pLocale)
    {
        lblTitle.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblName.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblCodeSymbol.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblTransaction.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblQuantity.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblPrice.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblOrderType.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblDuration.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblPlaceOn.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblReferenceNo.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblQuestion.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblCodeResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblQtyResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblPriceResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblPlaceOnResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblRefNoResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        taNameResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblTransResult.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblOrderTypeResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblDurationResult.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblQuestion.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        btnOK.setFont(ClientAppLoader.getPlainButtonFont(pLocale));
    }

    public void setText(Locale pLocale)
    {
        super.setText(pLocale);
        currentLocale = pLocale;
        setFont(pLocale);
        if(hkOptFlag)
            refresh(currentHKVO);
        else
            refresh(currentUSVO);
        lblTitle.setText(msgConf.getUIMessages("TRADING.ORDER_RECEIVED", pLocale));
        lblName.setText(msgConf.getUIMessages("TRADING.NAME", pLocale));
        lblCodeSymbol.setText(msgConf.getUIMessages("TRADING.CODE", pLocale));
        lblTransaction.setText(msgConf.getUIMessages("TRADING.TRANSACTION", pLocale));
        lblQuantity.setText(msgConf.getUIMessages("TRADING.QUANTITY", pLocale));
        lblPrice.setText(msgConf.getUIMessages("TRADING.PRICE", pLocale));
        lblOrderType.setText(msgConf.getUIMessages("TRADING.ORDER_TYPE", pLocale));
        lblDuration.setText(msgConf.getUIMessages("TRADING.DURATION", pLocale));
        lblPlaceOn.setText(msgConf.getUIMessages("TRADING.PLACED_ON", pLocale));
        lblReferenceNo.setText(msgConf.getUIMessages("TRADING.REFERENCE_NO", pLocale));
        lblQuestion.setText(msgConf.getUIMessages("TRADING.CONFIRM_MSG", pLocale));
        btnOK.setText(msgConf.getUIMessages("TRADING.OK", pLocale));
    }

    private void initGUI(Locale pLocale)
    {
        setLayout(null);
        setPreferredSize(new Dimension(710, 210));
        lblTitle = new JLabel();
        add(lblTitle);
        lblName = new JLabel();
        lblName.setHorizontalAlignment(4);
        add(lblName);
        lblCodeSymbol = new JLabel();
        lblCodeSymbol.setHorizontalAlignment(4);
        add(lblCodeSymbol);
        lblTransaction = new JLabel();
        lblTransaction.setHorizontalAlignment(4);
        add(lblTransaction);
        lblQuantity = new JLabel();
        lblQuantity.setHorizontalAlignment(4);
        add(lblQuantity);
        lblPrice = new JLabel();
        lblPrice.setHorizontalAlignment(4);
        add(lblPrice);
        lblOrderType = new JLabel();
        lblOrderType.setHorizontalAlignment(4);
        add(lblOrderType);
        lblDuration = new JLabel();
        lblDuration.setHorizontalAlignment(4);
        add(lblDuration);
        lblPlaceOn = new JLabel();
        lblPlaceOn.setHorizontalAlignment(4);
        add(lblPlaceOn);
        lblReferenceNo = new JLabel();
        lblReferenceNo.setHorizontalAlignment(4);
        add(lblReferenceNo);
        taNameResult = new JTextArea();
        taNameResult.setOpaque(false);
        taNameResult.setEditable(false);
        taNameResult.setLineWrap(true);
        taNameResult.setWrapStyleWord(true);
        add(taNameResult);
        lblCodeResult = new JLabel();
        add(lblCodeResult);
        lblTransResult = new JLabel();
        add(lblTransResult);
        lblQtyResult = new JLabel();
        add(lblQtyResult);
        lblPriceResult = new JLabel();
        add(lblPriceResult);
        lblDurationResult = new JLabel();
        add(lblDurationResult);
        lblOrderTypeResult = new JLabel();
        add(lblOrderTypeResult);
        lblPlaceOnResult = new JLabel();
        add(lblPlaceOnResult);
        lblRefNoResult = new JLabel();
        add(lblRefNoResult);
        lblQuestion = new JLabel();
        lblQuestion.setHorizontalAlignment(0);
        add(lblQuestion);
        btnOK = new JButton();
        add(btnOK);
        lblTitle.setBounds(13, 1, 207, 20);
        lblName.setBounds(intHIndex + 0, 30 + intVIndex, 120, 20);
        lblCodeSymbol.setBounds(intHIndex + 0, 48 + intVIndex, 120, 20);
        lblTransaction.setBounds(intHIndex + 0, 66 + intVIndex, 120, 20);
        lblQuantity.setBounds(intHIndex + 0, 84 + intVIndex, 120, 20);
        lblPrice.setBounds(intHIndex + 0, 102 + intVIndex, 120, 20);
        lblOrderType.setBounds(intHIndex + 0, 120 + intVIndex, 120, 20);
        lblDuration.setBounds(intHIndex + 0, 138 + intVIndex, 120, 20);
        lblPlaceOn.setBounds(intHIndex + 0, 156 + intVIndex, 120, 20);
        lblReferenceNo.setBounds(intHIndex + 0, 174 + intVIndex, 120, 20);
        taNameResult.setBounds(intHIndex + 135, 16 + intVIndex, 590, 35);
        lblCodeResult.setBounds(intHIndex + 135, 48 + intVIndex, 150, 20);
        lblTransResult.setBounds(intHIndex + 135, 66 + intVIndex, 150, 20);
        lblQtyResult.setBounds(intHIndex + 135, 84 + intVIndex, 150, 20);
        lblPriceResult.setBounds(intHIndex + 135, 102 + intVIndex, 150, 20);
        lblOrderTypeResult.setBounds(intHIndex + 135, 120 + intVIndex, 300, 20);
        lblDurationResult.setBounds(intHIndex + 135, 138 + intVIndex, 300, 20);
        lblPlaceOnResult.setBounds(intHIndex + 135, 156 + intVIndex, 120, 20);
        lblRefNoResult.setBounds(intHIndex + 135, 174 + intVIndex, 260, 20);
        lblQuestion.setBounds(intHIndex + 80 + 225, 80, 400, 20);
        btnOK.setBounds(intHIndex + 80 + 350 + 15, 110, 120, 25);
        btnOK.setActionCommand("OK");
        btnOK.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e)
    {
        PerformanceLogger.startAppTimer();
        String strActionType = e.getActionCommand();
        OptConfirmAction confirmAction = new OptConfirmAction();
        confirmAction.doProcess(getInputValue(e.getActionCommand()), strActionType);
        PerformanceLogger.stopAppTimer();
        PerformanceLogger.doLog((new StringBuilder()).append(getScreenName()).append(".").append(strActionType).toString());
    }

    public void refresh()
    {
        setDefFocus();
    }

    public void refresh(ResponseVO pResponseVO)
    {
        if(pResponseVO == null)
        {
            lblCodeResult.setText("");
            lblTransResult.setText("");
            lblQtyResult.setText("");
            lblPriceResult.setText("");
            lblDurationResult.setText("");
            lblOrderTypeResult.setText("");
            lblPlaceOnResult.setText("");
            lblRefNoResult.setText("");
            taNameResult.setText("");
            return;
        }
        if(pResponseVO instanceof SendHKOptionVO)
        {
            currentHKVO = (SendHKOptionVO)pResponseVO;
            hkOptFlag = true;
            lblCodeResult.setText(currentHKVO.getSymbol());
            String strTransaction = currentHKVO.getBuyOrSell();
            lblTransResult.setText(msgConf.getUIMessages(strTransaction, currentLocale));
            if(currentHKVO.getBuyOrSell().equals("BUY"))
            {
                setBackground(ClientAppConst.buyBackground);
                lblTransResult.setForeground(ClientAppConst.buyFontColor);
            } else
            {
                setBackground(ClientAppConst.sellBackground);
                lblTransResult.setForeground(ClientAppConst.sellFontColor);
            }
            String strQty = StringUtil.formatQtyValue(currentHKVO.getQuantity());
            lblQtyResult.setText(strQty);
            String strCCY = msgConf.getUIMessages("HKD", currentLocale);
            String strPrice = StringUtil.formatPriceValue(currentHKVO.getPrice(), strCCY);
            lblDurationResult.setText(msgConf.getUIMessages("DAY", currentLocale));
            String strOrderType = currentHKVO.getOrderType();
            lblOrderTypeResult.setText(msgConf.getUIMessages(strOrderType, currentLocale));
            String strNoPriceTypes[] = ClientAppLoader.getNoPriceOrdTypes();
            boolean isNoPriceType = false;
            int i = 0;
            do
            {
                if(i >= strNoPriceTypes.length)
                    break;
                if(strNoPriceTypes[i].equals(strOrderType))
                {
                    isNoPriceType = true;
                    break;
                }
                i++;
            } while(true);
            if(isNoPriceType)
                lblPriceResult.setText("");
            else
                lblPriceResult.setText(strPrice);
            lblPlaceOnResult.setText(currentHKVO.getDate());
            lblRefNoResult.setText(currentHKVO.getReferenceNo());
            String strName;
            if(currentLocale.equals(ClientAppConst.ZH_CN) && currentHKVO.getName_CHS() != null && currentHKVO.getName_CHS().length() != 0)
                strName = currentHKVO.getName_CHS();
            else
            if(currentLocale.equals(ClientAppConst.ZH_HK) && currentHKVO.getName_CHI() != null && currentHKVO.getName_CHI().length() != 0)
                strName = currentHKVO.getName_CHI();
            else
                strName = currentHKVO.getName();
            FontMetrics fm = taNameResult.getFontMetrics(taNameResult.getFont());
            if(fm.stringWidth(strName) > 590)
            {
                if(currentLocale.equals(ClientAppConst.EN_US))
                {
                    taNameResult.setBounds(intHIndex + 135, 15 + intVIndex, 590, 40);
                    taNameResult.setWrapStyleWord(true);
                } else
                {
                    taNameResult.setBounds(intHIndex + 135, 13 + intVIndex, 590, 40);
                    taNameResult.setWrapStyleWord(false);
                }
            } else
            {
                taNameResult.setBounds(intHIndex + 135, 32 + intVIndex, 590, 20);
            }
            taNameResult.setText(strName);
        } else
        if(pResponseVO instanceof SendUSOptionVO)
        {
            currentUSVO = (SendUSOptionVO)pResponseVO;
            hkOptFlag = false;
            lblCodeResult.setText(currentUSVO.getSymbol());
            String strTransaction = currentUSVO.getBuyOrSell();
            lblTransResult.setText(msgConf.getUIMessages(strTransaction, currentLocale));
            if(currentUSVO.getBuyOrSell().equals("BUY"))
            {
                setBackground(ClientAppConst.buyBackground);
                lblTransResult.setForeground(ClientAppConst.buyFontColor);
            } else
            {
                setBackground(ClientAppConst.sellBackground);
                lblTransResult.setForeground(ClientAppConst.sellFontColor);
            }
            String strQty = StringUtil.formatQtyValue(currentUSVO.getQuantity());
            lblQtyResult.setText(strQty);
            String strCCY = msgConf.getUIMessages("USD", currentLocale);
            String strPrice = StringUtil.formatPriceValue(currentUSVO.getPrice(), strCCY);
            lblDurationResult.setText(msgConf.getUIMessages("DAY", currentLocale));
            String strOrderType = currentUSVO.getOrderType();
            lblOrderTypeResult.setText(msgConf.getUIMessages(strOrderType, currentLocale));
            String strNoPriceTypes[] = ClientAppLoader.getNoPriceOrdTypes();
            boolean isNoPriceType = false;
            int i = 0;
            do
            {
                if(i >= strNoPriceTypes.length)
                    break;
                if(strNoPriceTypes[i].equals(strOrderType))
                {
                    isNoPriceType = true;
                    break;
                }
                i++;
            } while(true);
            if(isNoPriceType)
                lblPriceResult.setText("");
            else
                lblPriceResult.setText(strPrice);
            lblPlaceOnResult.setText(currentUSVO.getDate());
            lblRefNoResult.setText(currentUSVO.getReferenceNo());
            String strName;
            if(currentLocale.equals(ClientAppConst.ZH_CN) && currentUSVO.getName_CHS() != null && currentUSVO.getName_CHS().length() != 0)
                strName = currentUSVO.getName_CHS();
            else
            if(currentLocale.equals(ClientAppConst.ZH_HK) && currentUSVO.getName_CHI() != null && currentUSVO.getName_CHI().length() != 0)
                strName = currentUSVO.getName_CHI();
            else
                strName = currentUSVO.getName();
            FontMetrics fm = taNameResult.getFontMetrics(taNameResult.getFont());
            if(fm.stringWidth(strName) > 590)
            {
                if(currentLocale.equals(ClientAppConst.EN_US))
                {
                    taNameResult.setBounds(intHIndex + 135, 15 + intVIndex, 590, 40);
                    taNameResult.setWrapStyleWord(true);
                } else
                {
                    taNameResult.setBounds(intHIndex + 135, 13 + intVIndex, 590, 40);
                    taNameResult.setWrapStyleWord(false);
                }
            } else
            {
                taNameResult.setBounds(intHIndex + 135, 32 + intVIndex, 590, 20);
            }
            taNameResult.setText(strName);
        }
        setDefFocus();
    }

    public HashMap getInputValue(String pActionType)
    {
        HashMap inputMap = new HashMap();
        inputMap.put("HK_OPTION_FLAG", new Boolean(hkOptFlag));
        return inputMap;
    }

    public boolean validate(String pActionType)
    {
        return true;
    }

    public void setDefFocus()
    {
        SwingUtilities.invokeLater(new Runnable() {

            public void run()
            {
                btnOK.requestFocus();
            }
        }
);
    }

    private JLabel lblTitle;
    private JLabel lblName;
    private JLabel lblCodeSymbol;
    private JLabel lblTransaction;
    private JLabel lblQuantity;
    private JLabel lblPrice;
    private JLabel lblOrderType;
    private JLabel lblDuration;
    private JLabel lblPlaceOn;
    private JLabel lblReferenceNo;
    private JTextArea taNameResult;
    private JLabel lblCodeResult;
    private JLabel lblTransResult;
    private JLabel lblQtyResult;
    private JLabel lblPriceResult;
    private JLabel lblDurationResult;
    private JLabel lblOrderTypeResult;
    private JLabel lblPlaceOnResult;
    private JLabel lblRefNoResult;
    private JLabel lblQuestion;
    private JButton btnOK;
    private MessagesConfigurator msgConf;
    private Locale currentLocale;
    private SendHKOptionVO currentHKVO;
    private SendUSOptionVO currentUSVO;
    private boolean hkOptFlag;
    int intHIndex;
    int intVIndex;

}
